﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace InterfaceHommeMachine
{
    
    class Texture
    {
        Dictionary<String, ImageBrush> textureMap;

        public Texture()
        {
            textureMap = new Dictionary<String,ImageBrush>();
            ImageBrush desert = new ImageBrush();
            ImageBrush plaine = new ImageBrush();
            ImageBrush montagne = new ImageBrush();
            ImageBrush fer = new ImageBrush();
            ImageBrush ville = new ImageBrush();
            ImageBrush fruit = new ImageBrush(System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.fruit.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()));
            ImageBrush info = new ImageBrush(System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.info.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()));
            ImageBrush eii = new ImageBrush(System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.eii.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()));
            ImageBrush gma = new ImageBrush(System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.gma.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()));
            ImageBrush gc = new ImageBrush(System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.gc.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()));
            ImageBrush src = new ImageBrush(System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.src.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()));
            ImageBrush mnt = new ImageBrush(System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.mnt.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()));
            ImageBrush stpi = new ImageBrush(System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.stpi.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()));
           
            desert.ImageSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.desert.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
            plaine.ImageSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.plaine.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
            montagne.ImageSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.montagne.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
            fer.ImageSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.fer.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
            ville.ImageSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.ville.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
            textureMap.Add("Desert", desert);
            textureMap.Add("Plaine", plaine);
            textureMap.Add("Montagne", montagne);
            textureMap.Add("Fer", fer);
            textureMap.Add("Fruit", fruit);
            textureMap.Add("Ville", ville);
            textureMap.Add("Eii", eii);
            textureMap.Add("Info", info);
            textureMap.Add("Gc", gc);
            textureMap.Add("Gma", gma);
            textureMap.Add("Mnt", mnt);
            textureMap.Add("Stpi", stpi);
            textureMap.Add("Src", src);
            
        }

        public ImageBrush getImage(String s)
        {
            if (textureMap.ContainsKey(s))
            {
                return textureMap[s];
            }
            else
            {
                throw new KeyNotFoundException();
            }
        }

        public static Brush convertirCouleur(System.Drawing.Color c)
        {
           return new SolidColorBrush(Color.FromArgb(c.A, c.R, c.G, c.B));
        }
    }
}
